1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module pango.PgFontMetrics;
26 
27 private import gobject.ObjectG;
28 private import linker.Loader;
29 private import pango.c.functions;
30 public  import pango.c.types;
31 
32 
33 /**
34  * A `PangoFontMetrics` structure holds the overall metric information
35  * for a font.
36  * 
37  * The information in a `PangoFontMetrics` structure may be restricted
38  * to a script. The fields of this structure are private to implementations
39  * of a font backend. See the documentation of the corresponding getters
40  * for documentation of their meaning.
41  * 
42  * For an overview of the most important metrics, see:
43  * 
44  * <picture>
45  * <source srcset="fontmetrics-dark.png" media="(prefers-color-scheme: dark)">
46  * <img alt="Font metrics" src="fontmetrics-light.png">
47  * </picture>
48  */
49 public class PgFontMetrics
50 {
51 	/** the main Gtk struct */
52 	protected PangoFontMetrics* pangoFontMetrics;
53 	protected bool ownedRef;
54 
55 	/** Get the main Gtk struct */
56 	public PangoFontMetrics* getPgFontMetricsStruct(bool transferOwnership = false)
57 	{
58 		if (transferOwnership)
59 			ownedRef = false;
60 		return pangoFontMetrics;
61 	}
62 
63 	/** the main Gtk struct as a void* */
64 	protected void* getStruct()
65 	{
66 		return cast(void*)pangoFontMetrics;
67 	}
68 
69 	/**
70 	 * Sets our main struct and passes it to the parent class.
71 	 */
72 	public this (PangoFontMetrics* pangoFontMetrics, bool ownedRef = false)
73 	{
74 		this.pangoFontMetrics = pangoFontMetrics;
75 		this.ownedRef = ownedRef;
76 	}
77 
78 	~this ()
79 	{
80 		if ( Linker.isLoaded(LIBRARY_PANGO[0]) && ownedRef )
81 			pango_font_metrics_unref(pangoFontMetrics);
82 	}
83 
84 
85 	/** */
86 	public static GType getType()
87 	{
88 		return pango_font_metrics_get_type();
89 	}
90 
91 	/**
92 	 * Gets the approximate character width for a font metrics structure.
93 	 *
94 	 * This is merely a representative value useful, for example, for
95 	 * determining the initial size for a window. Actual characters in
96 	 * text will be wider and narrower than this.
97 	 *
98 	 * Returns: the character width, in Pango units.
99 	 */
100 	public int getApproximateCharWidth()
101 	{
102 		return pango_font_metrics_get_approximate_char_width(pangoFontMetrics);
103 	}
104 
105 	/**
106 	 * Gets the approximate digit width for a font metrics structure.
107 	 *
108 	 * This is merely a representative value useful, for example, for
109 	 * determining the initial size for a window. Actual digits in
110 	 * text can be wider or narrower than this, though this value
111 	 * is generally somewhat more accurate than the result of
112 	 * pango_font_metrics_get_approximate_char_width() for digits.
113 	 *
114 	 * Returns: the digit width, in Pango units.
115 	 */
116 	public int getApproximateDigitWidth()
117 	{
118 		return pango_font_metrics_get_approximate_digit_width(pangoFontMetrics);
119 	}
120 
121 	/**
122 	 * Gets the ascent from a font metrics structure.
123 	 *
124 	 * The ascent is the distance from the baseline to the logical top
125 	 * of a line of text. (The logical top may be above or below the top
126 	 * of the actual drawn ink. It is necessary to lay out the text to
127 	 * figure where the ink will be.)
128 	 *
129 	 * Returns: the ascent, in Pango units.
130 	 */
131 	public int getAscent()
132 	{
133 		return pango_font_metrics_get_ascent(pangoFontMetrics);
134 	}
135 
136 	/**
137 	 * Gets the descent from a font metrics structure.
138 	 *
139 	 * The descent is the distance from the baseline to the logical bottom
140 	 * of a line of text. (The logical bottom may be above or below the
141 	 * bottom of the actual drawn ink. It is necessary to lay out the text
142 	 * to figure where the ink will be.)
143 	 *
144 	 * Returns: the descent, in Pango units.
145 	 */
146 	public int getDescent()
147 	{
148 		return pango_font_metrics_get_descent(pangoFontMetrics);
149 	}
150 
151 	/**
152 	 * Gets the line height from a font metrics structure.
153 	 *
154 	 * The line height is the recommended distance between successive
155 	 * baselines in wrapped text using this font.
156 	 *
157 	 * If the line height is not available, 0 is returned.
158 	 *
159 	 * Returns: the height, in Pango units
160 	 *
161 	 * Since: 1.44
162 	 */
163 	public int getHeight()
164 	{
165 		return pango_font_metrics_get_height(pangoFontMetrics);
166 	}
167 
168 	/**
169 	 * Gets the suggested position to draw the strikethrough.
170 	 *
171 	 * The value returned is the distance *above* the
172 	 * baseline of the top of the strikethrough.
173 	 *
174 	 * Returns: the suggested strikethrough position, in Pango units.
175 	 *
176 	 * Since: 1.6
177 	 */
178 	public int getStrikethroughPosition()
179 	{
180 		return pango_font_metrics_get_strikethrough_position(pangoFontMetrics);
181 	}
182 
183 	/**
184 	 * Gets the suggested thickness to draw for the strikethrough.
185 	 *
186 	 * Returns: the suggested strikethrough thickness, in Pango units.
187 	 *
188 	 * Since: 1.6
189 	 */
190 	public int getStrikethroughThickness()
191 	{
192 		return pango_font_metrics_get_strikethrough_thickness(pangoFontMetrics);
193 	}
194 
195 	/**
196 	 * Gets the suggested position to draw the underline.
197 	 *
198 	 * The value returned is the distance *above* the baseline of the top
199 	 * of the underline. Since most fonts have underline positions beneath
200 	 * the baseline, this value is typically negative.
201 	 *
202 	 * Returns: the suggested underline position, in Pango units.
203 	 *
204 	 * Since: 1.6
205 	 */
206 	public int getUnderlinePosition()
207 	{
208 		return pango_font_metrics_get_underline_position(pangoFontMetrics);
209 	}
210 
211 	/**
212 	 * Gets the suggested thickness to draw for the underline.
213 	 *
214 	 * Returns: the suggested underline thickness, in Pango units.
215 	 *
216 	 * Since: 1.6
217 	 */
218 	public int getUnderlineThickness()
219 	{
220 		return pango_font_metrics_get_underline_thickness(pangoFontMetrics);
221 	}
222 
223 	alias doref = ref_;
224 	/**
225 	 * Increase the reference count of a font metrics structure by one.
226 	 *
227 	 * Returns: @metrics
228 	 */
229 	public PgFontMetrics ref_()
230 	{
231 		auto __p = pango_font_metrics_ref(pangoFontMetrics);
232 
233 		if(__p is null)
234 		{
235 			return null;
236 		}
237 
238 		return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) __p, true);
239 	}
240 
241 	/**
242 	 * Decrease the reference count of a font metrics structure by one.
243 	 *
244 	 * If the result is zero, frees the structure and any associated memory.
245 	 */
246 	public void unref()
247 	{
248 		pango_font_metrics_unref(pangoFontMetrics);
249 	}
250 }